ALMaSS  1.0
The Animal, Landscape and Man Simulation System
Roe_Fawn Class Reference

#include <Roe_all.h>

Inheritance diagram for Roe_Fawn:
Roe_Base TAnimal TALMaSSObject

Public Member Functions

virtual void On_IsDead (Roe_Base *Someone, int whos_dead, bool fawn)
 
virtual void On_ChangeGroup (int newgroup)
 
virtual void On_MumAbandon (Roe_Female *mum)
 
virtual void BeginStep (void)
 
virtual void Step (void)
 
virtual void EndStep (void)
 
virtual void On_EndGroup ()
 
 Roe_Fawn (int x, int y, int size, int group, bool sex, Landscape *L, RoeDeer_Population_Manager *RPM)
 
virtual ~Roe_Fawn ()
 
- Public Member Functions inherited from Roe_Base
unsigned IsAlive ()
 
int SupplyReserves ()
 
virtual void Send_IsDead ()
 
RoeDeerInfo SupplyInfo ()
 
virtual int WhatState ()
 
 Roe_Base (int x, int y, Landscape *L, RoeDeer_Population_Manager *RPM)
 
virtual ~Roe_Base ()
 
- Public Member Functions inherited from TAnimal
unsigned SupplyFarmOwnerRef ()
 
AnimalPosition SupplyPosition ()
 
APoint SupplyPoint ()
 
int SupplyPolygonRef ()
 
int Supply_m_Location_x ()
 
int Supply_m_Location_y ()
 
virtual void KillThis ()
 
virtual void CopyMyself ()
 
void SetX (int a_x)
 
void SetY (int a_y)
 
 TAnimal (int x, int y, Landscape *L)
 
virtual void ReinitialiseObject (int x, int y, Landscape *L)
 Used to re-use an object - must be implemented in descendent classes. More...
 
virtual void Dying ()
 
void CheckManagement (void)
 
void CheckManagementXY (int x, int y)
 
virtual bool OnFarmEvent (FarmToDo)
 
- Public Member Functions inherited from TALMaSSObject
int GetCurrentStateNo ()
 Returns the current state number. More...
 
void SetCurrentStateNo (int a_num)
 Sets the current state number. More...
 
bool GetStepDone ()
 Returns the step done indicator flag. More...
 
void SetStepDone (bool a_bool)
 Sets the step done indicator flag. More...
 
virtual void ReinitialiseObject ()
 Used to re-use an object - must be implemented in descendent classes. More...
 
 TALMaSSObject ()
 The constructor for TALMaSSObject. More...
 
virtual ~TALMaSSObject ()
 The destructor for TALMaSSObject. More...
 
void OnArrayBoundsError ()
 Used for debugging only, tests basic object properties. More...
 

Public Attributes

int m_MyGroup
 
int m_MinInState [6]
 
- Public Attributes inherited from Roe_Base
TRoeDeerStates CurrentRState
 
RoeDeer_Population_Managerm_OurPopulation
 
int m_Age
 
int m_Size
 
int m_RangeCentre_x
 
int m_RangeCentre_y
 
int m_Reserves
 
double m_HomeRange
 
int m_OldRange_x
 
int m_OldRange_y
 
int m_SearchRange
 
bool m_float
 
bool m_Disperse
 
bool m_HaveRange
 
Roe_FemaleMum
 
int m_ID
 
int m_FixlistNumber
 
bool m_Sex
 
bool m_IsDead
 
unsigned Alive
 

Protected Member Functions

void CareCounter (int state)
 
void SelectBedSite ()
 
int RunTo (int mum_x, int mum_y, bool p_IsSafe)
 
void Mature ()
 
void Send_InitCare ()
 
void On_UpdateGroup (int p_group_x, int p_group_y)
 
void On_ApproachOfDanger (int p_To_x, int p_To_y)
 
- Protected Member Functions inherited from Roe_Base
bool Running (int x, int y)
 
void Ignore (int p_To_x, int p_To_y)
 
int DistanceTo (int p_x, int p_y, int p_To_x, int p_To_y)
 
int DistanceToCC (int p_x, int p_y, int p_To_x, int p_To_y)
 
int DirectionTo (int p_x, int p_y, int p_To_x, int p_To_y)
 
int DirectionToCC (int p_x, int p_y, int p_To_x, int p_To_y)
 
int NextStep (int weight, int dir, int recurselevel)
 
int AssessHabitat (int polyref)
 
int AssessHabitat (int p_x, int p_y)
 
int LegalHabitat (int p_x, int p_y)
 
int LegalHabitatCC (int p_x, int p_y)
 
int Cover (int polyref)
 Calls the cover calculation for a given polyref. More...
 
int Cover (int p_x, int p_y)
 Calls the cover calculation for a given x,y location. More...
 
int CalcCover (TTypesOfLandscapeElement a_ele, int a_poly)
 The cover calculation for a given element type. More...
 
int CoverCC (int p_x, int p_y)
 
int NutriValue (int polyref)
 
int NutriValue (int p_x, int p_y)
 
int NutriValueCC (int p_x, int p_y)
 
int Feeding (bool p_Disperse)
 
void SeekCover (int threshold)
 
void SeekNutri (int p_threshold)
 
int ProbRoadCross (int p_x, int p_y, int p_width)
 
double CalculateRoadMortality (int p_x, int p_y, int p_width)
 
void WalkTo (int pos_x, int pos_y)
 
void WalkToCC (int pos_x, int pos_y)
 
- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. More...
 

Protected Attributes

Roe_Basem_MySiblings [3]
 
int BedSiteList [15][2]
 
int m_Agegroup
 
bool m_Mature
 
int m_MinHourlyCare
 
bool m_Orphan
 
bool m_InHide
 
int m_Bedsite_x
 
int m_BedSite_y
 
unsigned m_Count
 
int m_CareLastHour [6]
 
int m_memorypointer
 
- Protected Attributes inherited from Roe_Base
int timestep
 
int m_Cross_x
 
int m_Cross_y
 
double m_EnergyGained
 
int m_RecovCount
 
int m_RumiCount
 
int m_FeedCount
 
int m_LengthFeedPeriod
 
int m_LengthRuminate
 
int m_LastState
 
int m_danger_x
 
int m_danger_y
 
int m_distrc
 
int m_weightedstep
 
int SimW
 
int SimH
 
- Protected Attributes inherited from TAnimal
int m_Location_x
 
int m_Location_y
 
Landscapem_OurLandscape
 
- Protected Attributes inherited from TALMaSSObject
int m_CurrentStateNo
 The basic state number for all objects - '-1' indicates death. More...
 
bool m_StepDone
 Indicates whether the iterative step code is done for this timestep. More...
 

Private Member Functions

int FAInit (void)
 
int FASuckle (void)
 
int FAFeed (void)
 
int FARuminate (void)
 
int FAHide (void)
 
int FARecover (void)
 
int FARunToMother (void)
 
int FAOnNewDay (void)
 
int FAUpdateEnergy (void)
 
int FADie (void)
 

Constructor & Destructor Documentation

◆ Roe_Fawn()

Roe_Fawn::Roe_Fawn ( int  x,
int  y,
int  size,
int  group,
bool  sex,
Landscape L,
RoeDeer_Population_Manager RPM 
)

Roe_Fawn::Roe_Fawn - constructor for fawn object. Sets all attributes.

1247  : Roe_Base (x,y,L,RPM)
1248 {
1249  m_Age = 0;
1250  m_Sex=sex;
1251  m_Mature=false;
1252  m_IsDead=false;
1253  m_Orphan=false;
1254  m_InHide=false;
1255  m_Agegroup = 0;
1256  m_MinHourlyCare=0;
1257  m_Bedsite_x=0;
1258  m_BedSite_y=0;
1259  m_LastState=37; //Feed. Could be any safe state
1261  m_memorypointer=-1;
1262  m_SearchRange=200; //same for all fawns
1263  m_Count=0;
1264  //set pointers to NULL
1265  m_Size=size;
1266  m_MyGroup=group;
1267  for(int i=0;i<3;i++) m_MySiblings[i] = NULL;
1268 
1269  for(int i=0;i<6;i++) m_CareLastHour[i] = 0;
1270  for (int i=0;i<6;i++) m_MinInState[i] = 0;
1271  for (int i=0;i<15;i++)
1272  {
1273  BedSiteList[i][0]=-1;
1274  BedSiteList[i][1]=-1;
1275  }
1276  m_Reserves=5;
1277 }
int m_LengthFeedPeriod
Definition: Roe_all.h:136
bool m_Sex
Definition: Roe_all.h:120
bool m_IsDead
Definition: Roe_all.h:121
int m_Size
Definition: Roe_all.h:106
int m_SearchRange
Definition: Roe_all.h:113
int m_LastState
Definition: Roe_all.h:138
int m_Reserves
Definition: Roe_all.h:109
int m_Age
Definition: Roe_all.h:105
Roe_Base(int x, int y, Landscape *L, RoeDeer_Population_Manager *RPM)
Definition: Roe_base.cpp:1625
int m_BedSite_y
Definition: Roe_all.h:277
bool m_Orphan
Definition: Roe_all.h:274
Roe_Base * m_MySiblings[3]
Definition: Roe_all.h:269
int m_MinInState[6]
Definition: Roe_all.h:293
int m_MyGroup
Definition: Roe_all.h:292
int m_MinHourlyCare
Definition: Roe_all.h:273
bool m_Mature
Definition: Roe_all.h:272
int m_Bedsite_x
Definition: Roe_all.h:276
int BedSiteList[15][2]
Definition: Roe_all.h:270
int m_memorypointer
Definition: Roe_all.h:283
bool m_InHide
Definition: Roe_all.h:275
int m_Agegroup
Definition: Roe_all.h:271
int m_CareLastHour[6]
Definition: Roe_all.h:279
unsigned m_Count
Definition: Roe_all.h:278

References BedSiteList, Roe_Base::m_Age, m_Agegroup, m_Bedsite_x, m_BedSite_y, m_CareLastHour, m_Count, m_InHide, Roe_Base::m_IsDead, Roe_Base::m_LastState, Roe_Base::m_LengthFeedPeriod, m_Mature, m_memorypointer, m_MinHourlyCare, m_MinInState, m_MyGroup, m_MySiblings, m_Orphan, Roe_Base::m_Reserves, Roe_Base::m_SearchRange, Roe_Base::m_Sex, and Roe_Base::m_Size.

◆ ~Roe_Fawn()

Roe_Fawn::~Roe_Fawn ( )
virtual
1280 {
1281  //remove yourself from group
1282 
1284  m_MyGroup=-1;
1285 
1286  for(int i=0;i<3;i++)
1287  {
1288  if(m_MySiblings[i]!=NULL)
1289  {
1290  m_MySiblings[i]=NULL;
1291  }
1292  }
1293 }
RoeDeer_Population_Manager * m_OurPopulation
Definition: Roe_all.h:104
bool RemoveFromGroup(Roe_Base *p_deer, int TheGroup)
Definition: Roe_Population_Manager.cpp:1430

References m_MyGroup, m_MySiblings, Roe_Base::m_OurPopulation, and RoeDeer_Population_Manager::RemoveFromGroup().

Member Function Documentation

◆ BeginStep()

void Roe_Fawn::BeginStep ( void  )
virtual

Roe_Fawn::BeginStep - checks if fawn object is dead

Reimplemented from Roe_Base.

751 {
752  #ifdef JUJ__Debug3
753  if(IsAlive()!=0x0DEADC0DE)
754  {
755  m_OurLandscape ->Warn("Roe_Fawn:BeginStep():Deadcode warning!","");
756  exit( 1 );
757  }
758  #endif
759  if (CurrentRState==rds_FADeathState) return;
760 }
@ rds_FADeathState
Definition: Roe_all.h:92
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
unsigned IsAlive()
Definition: Roe_all.h:123
TRoeDeerStates CurrentRState
Definition: Roe_all.h:103
Landscape * m_OurLandscape
Definition: PopulationManager.h:229

References Roe_Base::CurrentRState, Roe_Base::IsAlive(), TAnimal::m_OurLandscape, rds_FADeathState, and Landscape::Warn().

◆ CareCounter()

void Roe_Fawn::CareCounter ( int  state)
protected

Roe_Fawn::CareCounter - is called at the beginning of every timestep and keeps track of dynamic list that counts last 6 timesteps as '1' if fawn has received the required care and '0' if not.

1013 {
1014  m_Count %= 6;
1015  #ifdef JUJ__Debug2
1016  if (m_Count>5)
1017  {
1018  m_OurLandscape ->Warn("Roe_Fawn:CareCounter: variable out of range!","");
1019  exit( 1 );
1020  }
1021  #endif
1022 
1023  m_CareLastHour[m_Count]=state;
1024  m_Count++;
1025 }

References m_CareLastHour, m_Count, TAnimal::m_OurLandscape, and Landscape::Warn().

Referenced by FAFeed(), FAHide(), FARecover(), FARuminate(), FARunToMother(), and FASuckle().

◆ EndStep()

void Roe_Fawn::EndStep ( void  )
virtual

Roe_Fawn::EndStep - checks if fawn object is dead and adds to number of timesteps. If 1 whole day has passed, current state is set to FOnNewDay

Reimplemented from Roe_Base.

989 {
990  #ifdef JUJ__Debug3
991  if(IsAlive()!=0x0DEADC0DE)
992  {
993  m_OurLandscape ->Warn("Roe_Fawn:EndStep():Deadcode warning!","");
994  exit( 1 );
995  }
996  #endif
997  if (CurrentRState==rds_FADeathState) return;
998 
999  timestep++;
1000  if (m_OurPopulation->StepCounter %144==0) //1 day has passed
1001  {
1002  m_weightedstep=0;
1004  }
1005 }
@ rds_FAOnNewDay
Definition: Roe_all.h:60
int timestep
Definition: Roe_all.h:128
int m_weightedstep
Definition: Roe_all.h:143
long StepCounter
Definition: Roe_all.h:505

References Roe_Base::CurrentRState, Roe_Base::IsAlive(), TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, Roe_Base::m_weightedstep, rds_FADeathState, rds_FAOnNewDay, RoeDeer_Population_Manager::StepCounter, Roe_Base::timestep, and Landscape::Warn().

◆ FADie()

int Roe_Fawn::FADie ( void  )
private

Roe_Fawn::FADie - function for managing death of a fawn object. The fawn object sends message to siblings and mom. The fawn adds itself to list of dead animals. Function returns dead state. Calls functions On_IsDead().

692 {
693  #ifdef JUJ__Debug3
694  if(IsAlive()!=0x0DEADC0DE)
695  {
696  m_OurLandscape ->Warn("Roe_Fawn:FADie():Deadcode warning!","");
697  exit( 1 );
698  }
699  #endif
700 
701  //add yourself to list of dead animals
702  int sex;
703  if(m_Sex) sex=1;
704  else sex=2;
705  for(int i=0;i<2000;i++)
706  {
707  if(m_OurPopulation->DeadList[i][0] == 0) //empty entrance
708  {
709  m_OurPopulation->DeadList[i][0] = sex; //'1' for male, '2' for female
710  m_OurPopulation->DeadList[i][1] = m_Age; //age in days
711  break;
712  }
713  }
714  //tell siblings
715  for (int i=0; i<3; i++)
716  {
717  #ifdef JUJ__Debug3
718  if((m_MySiblings[i]!=NULL)&&(m_MySiblings[i]->IsAlive()!=0x0DEADC0DE))
719  {
720  m_OurLandscape ->Warn("Roe_Fawn:FADie():Bad pointer to m_MySiblings[i]!","");
721  exit( 1 );
722  }
723  #endif
724  if (m_MySiblings[i] != NULL)
725  {
726  m_MySiblings[i]->On_IsDead(this,4,true); //'4' indicates siblings
727  }
728  }
729 
730  if(Mum!=NULL) //tell mum
731  {
732  #ifdef JUJ__Debug3
733  if(Mum->IsAlive()!=0x0DEADC0DE)
734  {
735  m_OurLandscape ->Warn("Roe_Fawn:FADie():Deadcode warning, Mum!","");
736  exit( 1 );
737  }
738  #endif
739  //send to mother
740  Mum->On_IsDead(this,3,true); //'3' indicates offspring
741  }
742 
743  m_CurrentStateNo=-1;
744  return 46; //DeathState
745 }
virtual void On_IsDead(Roe_Base *, int, bool)
Definition: Roe_all.h:217
Roe_Female * Mum
Definition: Roe_all.h:117
virtual void On_IsDead(Roe_Base *Someone, int whos_dead, bool fawn)
Definition: Roe_female.cpp:1925
int DeadList[2000][2]
Definition: Roe_all.h:504
int m_CurrentStateNo
The basic state number for all objects - '-1' indicates death.
Definition: PopulationManager.h:116

References RoeDeer_Population_Manager::DeadList, Roe_Base::IsAlive(), Roe_Base::m_Age, TALMaSSObject::m_CurrentStateNo, m_MySiblings, TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, Roe_Base::m_Sex, Roe_Base::Mum, Roe_Base::On_IsDead(), Roe_Female::On_IsDead(), and Landscape::Warn().

Referenced by Step().

◆ FAFeed()

int Roe_Fawn::FAFeed ( void  )
private

Roe_Fawn::FAFeed - Determines possible energy gain per minute feeding of fawn object by looking at nutritional value of habitat, and thuis determines if habitat is suited for feeding. If so adds nutritional value to the energy gained by the fawn object. If the fawn is not an orphan fawn is weighted back towards mother (via a simple semi-random walk) if too far away. Orphans are weighted back towards their rangecentre instead. If the feeding time of the fawn object is long enough state is set to ruminate, else to stay in feeding state. If fawn object is less than 60 days old, it may initiate a suckle period or set state to hide. Calls functions NutriValue(), SupplyPosition(), DistanceTo(), On_InitCare(), DirectionTo()

81 {
82  //a simple semirandom walk. Fawn is weighted back toards mother if too far away
83  //Orphans are weighted back towards their rangecentre instead
84  #ifdef JUJ__Debug3
85  if(IsAlive()!=0x0DEADC0DE)
86  {
87  m_OurLandscape ->Warn("Roe_Fawn:FFeed():Deadcode warning!","");
88  exit( 1 );
89  }
90  #endif
91  #ifdef JUJ__Debug1
92  if((Mum==NULL)&&(m_Orphan==false))
93  {
94  m_OurLandscape ->Warn("Roe_Fawn:FFeed():Warning!","");
95  exit( 1 );
96  }
97  #endif
98 
99  m_MinInState[4]++; //add 1 timestep to time spend in this state
100  m_FeedCount++; //add 1 to count for this feeding bout
101  m_LastState=37; //possible to return to this state after disturbance
102  int nutri=NutriValue(m_Location_x,m_Location_y); //possible energy gain per minut
103 
104  if(nutri>MinNutri) //can feed here
105  {
106  m_EnergyGained+=nutri; //add this to total count for today
107  }
108  int weight=-1;
109  if(m_Orphan==false)
110  {
111  #ifdef JUJ__Debug3
112  if(Mum->IsAlive()!=0x0DEADC0DE)
113  {
114  m_OurLandscape ->Warn("Roe_Fawn:FFeed():Deadcode warning, Mum!","");
115  exit( 1 );
116  }
117  #endif
118  //set care counter right if fawn is < 60 days
119  if (m_Age<60) CareCounter(0); //no care received during this timestep
120  //get mothers position
122  //get distance to mother
123  int dist=DistanceTo(m_Location_x,m_Location_y,xy.m_x,xy.m_y);
124  if (dist<=MaxDistToMum) //OK, can walk in any direction
125  {
126  NextStep(0,0,0); //no weight, no directio
127  }
128  else // too far away, so find appropriate weight
129  {
130  if (dist<=(MaxDistToMum+25)) weight=1;
131  else if ((dist>MaxDistToMum+25)&&(dist<=MaxDistToMum+50)) weight=2;
132  else if ((dist>MaxDistToMum+50)&&(dist<=MaxDistToMum+75)) weight=3;
133  else if (dist>MaxDistToMum+75) weight=4;
134 
135  //get direction to mother
137  {
138  NextStep(weight,dir,0);
139  }
140  }
141  //decide where to go to from here
142  if (m_Age<60)
143  {
144  int care=0;
145  for (int j=0; j<6; j++) //last 6 timesteps
146  {
147  if (m_CareLastHour[j]==1) care++;
148  }
149  if (care<Minhrcare[m_Agegroup]) //is hungry
150  {
151  bool CanSuckle=Mum->On_InitCare(this);
152  if(CanSuckle==true) return 38; //Suckle
153  else return 37; //Feed
154  }
155  else
156  {
157  m_FeedCount=0;
158  return 29; //Hide
159  }
160  }
161  else // > 60 days old
162  {
163  if (m_FeedCount<=m_LengthFeedPeriod) //stay in feed
164  {
165  return 37;
166  }
167  else //ruminate
168  {
169  //for how long do you need to ruminate?
170  int month= m_OurLandscape->SupplyMonth();
171  m_LengthRuminate=(int) (m_FeedCount*IntakeRate[month-1]*0.1);
172  m_FeedCount=0; //leaves state, so set counter to zero
173  return 34; //Ruminate
174  }
175  }
176  }
177  else //m_Orphan==true, fawn checks for distance to rangecentre instead
178  {
179  //get distance to rangecentre
181  if (dist<=200) //OK, so walk in any direction
182  {
183  NextStep(0,0,0); //no weight, no direction
184  }
185  else // too far away, so find appropriate weight
186  {
187  if (dist<=(225)) weight=1;
188  else if ((dist>225)&&(dist<=250)) weight=2;
189  else if ((dist>250)&&(dist<=275)) weight=3;
190  else if (dist>275) weight=4;
191 
192  //get direction to range centre
194  {
195  NextStep(weight,dir,0);
196  }
197  }
198  //whereto next
199  if (m_FeedCount<m_LengthFeedPeriod) //stay in feed
200  {
201  return 37;
202  }
203  else
204  {
205  m_FeedCount=0; //leaves state, so set counter to zero
206  return 34; //Ruminate
207  }
208  }
209 }
const int MaxDistToMum
Definition: Roe_constants.cpp:23
const int MinNutri
Definition: Roe_constants.cpp:62
const float IntakeRate[12]
Definition: Roe_constants.cpp:56
const int Minhrcare[2]
Definition: Roe_constants.cpp:150
A class defining an animals position.
Definition: PopulationManager.h:170
unsigned m_x
Definition: PopulationManager.h:172
unsigned m_y
Definition: PopulationManager.h:173
int SupplyMonth(void)
Definition: landscape.h:1601
int DirectionTo(int p_x, int p_y, int p_To_x, int p_To_y)
Definition: Roe_base.cpp:802
int m_RangeCentre_y
Definition: Roe_all.h:108
int NutriValue(int polyref)
int m_RangeCentre_x
Definition: Roe_all.h:107
int m_FeedCount
Definition: Roe_all.h:135
double m_EnergyGained
Definition: Roe_all.h:132
int DistanceTo(int p_x, int p_y, int p_To_x, int p_To_y)
Definition: Roe_base.cpp:784
int m_LengthRuminate
Definition: Roe_all.h:137
int NextStep(int weight, int dir, int recurselevel)
Definition: Roe_base.cpp:1242
void CareCounter(int state)
Definition: Roe_fawn.cpp:1012
bool On_InitCare(Roe_Fawn *Fawn)
Definition: Roe_female.cpp:2033
int m_Location_y
Definition: PopulationManager.h:228
AnimalPosition SupplyPosition()
Definition: PopulationManager.cpp:1345
int m_Location_x
Definition: PopulationManager.h:225

References CareCounter(), Roe_Base::DirectionTo(), Roe_Base::DistanceTo(), IntakeRate, Roe_Base::IsAlive(), Roe_Base::m_Age, m_Agegroup, m_CareLastHour, Roe_Base::m_EnergyGained, Roe_Base::m_FeedCount, Roe_Base::m_LastState, Roe_Base::m_LengthFeedPeriod, Roe_Base::m_LengthRuminate, TAnimal::m_Location_x, TAnimal::m_Location_y, m_MinInState, m_Orphan, TAnimal::m_OurLandscape, Roe_Base::m_RangeCentre_x, Roe_Base::m_RangeCentre_y, AnimalPosition::m_x, AnimalPosition::m_y, MaxDistToMum, Minhrcare, MinNutri, Roe_Base::Mum, Roe_Base::NextStep(), Roe_Base::NutriValue(), Roe_Female::On_InitCare(), Landscape::SupplyMonth(), TAnimal::SupplyPosition(), and Landscape::Warn().

Referenced by Step().

◆ FAHide()

int Roe_Fawn::FAHide ( void  )
private

Roe_Fawn::FAHide - only fawn objects less than 60 days can be in the hide state. Sets fawn to hide and select hiding spot. The fawn will leave hide only if flushed or hungry. If fawns has been in hiding for more than 1 time step it will check if it is in need of care and is hungry. If so it may initiate a suckling session (if mother accepts) or if old enough to feed a feeding session. Checks if mother is dead, and if so the fawn will also die. Calls functions SelectBedSite(), On_InitCare(),

362 {
363  #ifdef JUJ__Debug3
364  if(IsAlive()!=0x0DEADC0DE)
365  {
366  m_OurLandscape ->Warn("Roe_Fawn:FAHide():Deadcode warning!","");
367  exit( 1 );
368  }
369  #endif
370  m_MinInState[2]++; //add 1 to time spend in this state
371  //set care counter right
372  CareCounter(0);
373  m_LastState=29;
374  m_InHide=true;
375  if(m_InHide==false) //first timestep in this state
376  {
377  SelectBedSite(); //will leave hide only if flushed or hungry
378  if(m_IsDead) return 43; //Die
379  }
380  else
381  {
382  //do fawn want to stay in this state?
383  int care=0; //sum of care last hour
384  for (int j=0; j<6; j++)
385  {
386  care += m_CareLastHour[j];
387  }
388  #ifdef JUJ__Debug1
389  if (Mum==NULL)
390  {
391  m_OurLandscape ->Warn("Roe_Fawn:FARuminate():NULL pointer,Mum!","");
392  exit( 1 );
393  }
394  #endif
395  if (care<Minhrcare[m_Agegroup]) //is hungry
396  {
397  bool CanSuckle=Mum->On_InitCare(this);
398  care=0;
399  if(CanSuckle==true)
400  {
401  m_InHide=false;
402  return 38; //suckle
403  }
404  else
405  {
406  if (m_Age>=14) //old enough to feed
407  {
408  m_InHide=false;
409  return 37; //feed
410  }
411  else return 29;
412  }
413  }
414  }
415  return 29; //stay
416 }
void SelectBedSite()
Definition: Roe_fawn.cpp:1137

References CareCounter(), Roe_Base::IsAlive(), Roe_Base::m_Age, m_Agegroup, m_CareLastHour, m_InHide, Roe_Base::m_IsDead, Roe_Base::m_LastState, m_MinInState, TAnimal::m_OurLandscape, Minhrcare, Roe_Base::Mum, Roe_Female::On_InitCare(), SelectBedSite(), and Landscape::Warn().

Referenced by Step().

◆ FAInit()

int Roe_Fawn::FAInit ( void  )
private

Roe_Fawn::FAInit - initial state of fawn object. Keeps track of mother and siblings. Returns suckling state. Calls SupplyInfo().

29 {
30  #ifdef JUJ__Debug3
31  if(IsAlive()!=0x0DEADC0DE)
32  {
33  m_OurLandscape ->Warn("Roe_Fawn:Init():Deadcode warning!","");
34  exit( 1 );
35  }
36  #endif
37  int count=0;
38  for (int i=0;i<20;i++)
39  {
40  #ifdef JUJ__Debug3
41  if(Mum->IsAlive()!=0x0DEADC0DE)
42  {
43  m_OurLandscape ->Warn("Roe_Fawn:Init():Deadcode warning, Mum!","");
44  exit( 1 );
45  }
46  #endif
47  if((Mum->m_MyYoung[i]!=NULL)&&(Mum->m_MyYoung[i]!=this))
48  {
49  #ifdef JUJ__Debug3
50  if(Mum->m_MyYoung[i]->IsAlive()!=0x0DEADC0DE)
51  {
52  m_OurLandscape ->Warn("Roe_Fawn:Init():Deadcode warning, Mum->m_MyYoung[i]!","");
53  exit( 1 );
54  }
55  #endif
56  RoeDeerInfo info = Mum->m_MyYoung[i]->SupplyInfo();
57  if(info.m_Age==m_Age)
58  {
59  m_MySiblings[count]=Mum->m_MyYoung[i];
60  count++;
61  }
62  }
63  }
64  return 38; //FASuckle
65 }
RoeDeerInfo SupplyInfo()
Definition: Roe_base.cpp:1668
Roe_Base * m_MyYoung[20]
Definition: Roe_all.h:311
Part of the basic ALMaSS system (obselete)
Definition: PopulationManager.h:187
int m_Age
Definition: PopulationManager.h:190

References Roe_Base::IsAlive(), RoeDeerInfo::m_Age, Roe_Base::m_Age, m_MySiblings, Roe_Female::m_MyYoung, TAnimal::m_OurLandscape, Roe_Base::Mum, Roe_Base::SupplyInfo(), and Landscape::Warn().

Referenced by Step().

◆ FAOnNewDay()

int Roe_Fawn::FAOnNewDay ( void  )
private

Roe_Fawn::FAOnNewDay - updates age of fawn object (+ 1 day), if age = 365 days, fawns is set to mature (creates an adult object) and fawn object dies. Checks for fawn mortality and updates age group of fawn. Calls functions Mature().

539 {
540  #ifdef JUJ__Debug3
541  if(IsAlive()!=0x0DEADC0DE)
542  {
543  m_OurLandscape ->Warn("Roe_Fawn:FAOnNewDay():Deadcode warning!","");
544  exit( 1 );
545  }
546  #endif
547 
548  m_Age++;
549  if(m_Age>=365) //adult
550  {
551  Mature();
552  return 43; //die
553  }
554  //Else find out if life expectancy has been reached
555  int mort;
556  long int die=random(100000); //since mort rates are multiplied with 100000 to
557  //produce int values
558  if (m_Age<180)
559  mort=(int)FawnDMR[0];
560  else
561  mort=(int)FawnDMR[1];
562  if (die<mort)
563  {
564  return 43; //Die
565  }
566  else //still alive
567  {
568  //set current agegroup
569  if(m_Age<10) m_Agegroup=0;
570  else if(m_Age<=60) m_Agegroup=1;
571  else if (m_Age<=120) m_Agegroup=2;
572  else if (m_Age<=300) m_Agegroup=3;
573  else m_Agegroup=4;
574  }
575  return 6; //Update energy
576 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
const float FawnDMR[2]
Definition: Roe_constants.cpp:144
void Mature()
Definition: Roe_fawn.cpp:583

References FawnDMR, Roe_Base::IsAlive(), Roe_Base::m_Age, m_Agegroup, TAnimal::m_OurLandscape, Mature(), random(), and Landscape::Warn().

Referenced by Step().

◆ FARecover()

int Roe_Fawn::FARecover ( void  )
private

Roe_Fawn::FARecover - Recovery from reaction to a disturbance. Fawn may return to last state, a new state such as suckling, feeding or hiding (if less than 14 days old) or may stay in the recovery state. Calls function On_InitCare()

427 {
428  #ifdef JUJ__Debug3
429  if(IsAlive()!=0x0DEADC0DE)
430  {
431  m_OurLandscape ->Warn("Roe_Fawn:FARécover():Deadcode warning!","");
432  exit( 1 );
433  }
434  #endif
435  //Need to count amount of time in state during the present
436  //period of recov. (m_RecovCount) and set this to 0 when state is left.
437  m_MinInState[1]++; //add 1 to time spend in this state
438  //set care counter right if fawn is < 60 days
439  if (m_Age<60) CareCounter(0);
440 
441  m_LastState=24; //possible to return to this state after disturb. or newday
443  {
444  m_RecovCount++; //add 1 to time spend in recover and stay here
445  return 24;
446  }
448  //return to feed or suckle with certain probability
449  {
450  int stop = random(100);
451  if (stop>10) //stay in recover
452  {
453  m_RecovCount++; //add 1 to time spend in this state
454  return 24; //recover
455  }
456  }
457  else if (m_RecovCount>=MaxRecoveryTime) //go to either feed or suckle
458  {
459  m_RecovCount=0; //leaves state, so set counter=0
460  if (m_Age<60) //young fawn, ask mum for careperiod
461  {
462  #ifdef JUJ__Debug1
463  if(Mum==NULL)
464  {
465  m_OurLandscape ->Warn("Roe_Fawn:FARecover():NULL pointer, Mum!","");
466  exit( 1 );
467  }
468  #endif
469  #ifdef JUJ__Debug3
470  if(Mum->IsAlive()!=0x0DEADC0DE)
471  {
472  m_OurLandscape ->Warn("Roe_Fawn:FARecover():Deadcode warning, Mum!","");
473  exit( 1 );
474  }
475  #endif
476  bool CanSuckle=Mum->On_InitCare(this);
477  if(CanSuckle==true)
478  {
479  return 38;
480  }
481  else if ((CanSuckle==false)&&(m_Age<14))//not old enough to feed, so go to hide
482  {
483  return 29; //Hide
484  }
485  else //go to feed
486  {
487  m_FeedCount=0;
488  return 37;
489  }
490  }
491  }
492  return 37; // else feed
493 }
const int MaxRecoveryTime
Definition: Roe_constants.cpp:39
const int AverageRecoveryTime
Definition: Roe_constants.cpp:38
int m_RecovCount
Definition: Roe_all.h:133

References AverageRecoveryTime, CareCounter(), Roe_Base::IsAlive(), Roe_Base::m_Age, Roe_Base::m_FeedCount, Roe_Base::m_LastState, m_MinInState, TAnimal::m_OurLandscape, Roe_Base::m_RecovCount, MaxRecoveryTime, Roe_Base::Mum, Roe_Female::On_InitCare(), random(), and Landscape::Warn().

Referenced by Step().

◆ FARuminate()

int Roe_Fawn::FARuminate ( void  )
private

Roe_Fawn::FARuminate - Function for ruminating. When fawns are older than 2 month their ruminating activity is equal to an adult. Checks for good spot to rest and amount of time spent ruminating. Ruminate activity cannot be seperated from other kinds of inactivity. It is also assumed that ruminating takes place while recovering after disturbance. Need to count amount of time spend in this state during this period of ruminating and in total last 24 hrs. Returns values for either stay ruminating, feed or dispersal (or die). Calls function Cover().

298 {
299  #ifdef JUJ__Debug3
300  if(IsAlive()!=0x0DEADC0DE)
301  {
302  m_OurLandscape ->Warn("Roe_Fawn:FARuminate():Deadcode warning!","");
303  exit( 1 );
304  }
305  #endif
306  //When fawns are older than 2 month their ruminating activity is equal to an adult
307  //Ruminating cannot be separated from other kinds of inactivity.
308  //It is also assumed that ruminating takes place while recovering after
309  //disturbance. Need to count amount of time spend in this state during
310  //this period of ruminating and in total last 24 hrs
311  m_MinInState[3]++; //add 1 to time spend in this state
312  int min;
313 
314  //allow roe the opportunity to return to this state after disturbance
315  m_LastState=34; //Ruminate
316  if (m_Age < 60) CareCounter(0);
317  if (m_RumiCount==0) //first step so make sure this is a good spot to rest
318  {
319  int cover=Cover(m_Location_x,m_Location_y);
320  //get month
321  int month=m_OurLandscape->SupplyMonth();
322  if((month>=5)&&(month<=9)) min=CoverThreshold2; //summer
323  else min=CoverThreshold1; //winter
324  if (cover<min)// habitat unsuitable or cover very poor, so look for better spot
325  {
326  SeekCover(2);
327  if(m_IsDead) return 43; //Die
328  else
329  {
330  m_RumiCount++;
331  return 34;
332  }
333  }
334  else //habitat OK, so no need to do anything
335  {
336  m_RumiCount++; //add 1 to counter
337  return 34; //return to this state next time step
338  }
339  }
340  else if(m_RumiCount<m_LengthRuminate) //still less than average
341  {
342  m_RumiCount++; //add 1 to counter
343  return 34; //stay
344  }
345  else //return to feed
346  {
347  m_RumiCount=0;
348  return 37; //Feed
349  }
350 }
const int CoverThreshold2
Definition: Roe_constants.cpp:41
const int CoverThreshold1
Definition: Roe_constants.cpp:40
void SeekCover(int threshold)
Definition: Roe_base.cpp:42
int Cover(int polyref)
Calls the cover calculation for a given polyref.
Definition: Roe_base.cpp:943
int m_RumiCount
Definition: Roe_all.h:134

References CareCounter(), Roe_Base::Cover(), CoverThreshold1, CoverThreshold2, Roe_Base::IsAlive(), Roe_Base::m_Age, Roe_Base::m_IsDead, Roe_Base::m_LastState, Roe_Base::m_LengthRuminate, TAnimal::m_Location_x, TAnimal::m_Location_y, m_MinInState, TAnimal::m_OurLandscape, Roe_Base::m_RumiCount, Roe_Base::SeekCover(), Landscape::SupplyMonth(), and Landscape::Warn().

Referenced by Step().

◆ FARunToMother()

int Roe_Fawn::FARunToMother ( void  )
private

Roe_Fawn::FARunToMother - the fawn object gets it's mothers position and will run to her avoiding non-habitat. Calls SupplyPosition(), RunTo()

502 {
503  #ifdef JUJ__Debug3
504  if(IsAlive()!=0x0DEADC0DE)
505  {
506  m_OurLandscape ->Warn("Roe_Fawn:FARunToMother():Deadcode warning!","");
507  exit( 1 );
508  }
509  #endif
510  #ifdef JUJ__Debug1
511  if(Mum==NULL)
512  {
513  m_OurLandscape ->Warn("Roe_Fawn:FARecover():NULL pointer,Mum","");
514  exit( 1 );
515  }
516  #endif
517  m_MinInState[0]++; //add 1 to time spend in this state
518  //set care counter right if fawn is < 60 days
519  if (m_Age<60) CareCounter(0);
520 
521  bool p_IsSafe=false;
522  //Get mothers position and run to her avoiding non-habitat
524 
525  RunTo(xy.m_x,xy.m_y,false);
526  if(m_IsDead) return 43; //Die
527  else if (p_IsSafe) return 24; //Recover
528  else return 21; //RunToMother
529 }
int RunTo(int mum_x, int mum_y, bool p_IsSafe)
Definition: Roe_fawn.cpp:1033

References CareCounter(), Roe_Base::IsAlive(), Roe_Base::m_Age, Roe_Base::m_IsDead, m_MinInState, TAnimal::m_OurLandscape, AnimalPosition::m_x, AnimalPosition::m_y, Roe_Base::Mum, RunTo(), TAnimal::SupplyPosition(), and Landscape::Warn().

Referenced by Step().

◆ FASuckle()

int Roe_Fawn::FASuckle ( void  )
private

Roe_Fawn::FASuckle - Sets energy gain from suckling as 75000 per 10 minutes. The fawn object can only be in this state if CanSuckle=true. A careperiod cannot last more than 1 timestep. Sets care counter (if fawns is < 60 days) and determines whether fawn want to initiate another careperiod and whether or not it is still hungry (dependent on minimum care time for age group) and wants to initiate more suckling ( which may be refused by mother). Either returns states suckling, feed (if mother refused suckling), or hide if fawn is less than 14 days. Calls functions On_InitCare(), SupplyPosition(), DistanceTo(), WalkTo(), On_EndCare()

225 {
226  #ifdef JUJ__Debug3
227  if(IsAlive()!=0x0DEADC0DE)
228  {
229  m_OurLandscape ->Warn("Roe_Fawn:FFeed():Deadcode warning!","");
230  exit( 1 );
231  }
232  if(Mum->IsAlive()!=0x0DEADC0DE)
233  {
234  m_OurLandscape ->Warn("Roe_Fawn:FFeed():Deadcode warning, Mum!","");
235  exit( 1 );
236  }
237  #endif
238  #ifdef JUJ__Debug1
239  if(Mum==NULL)
240  {
241  m_OurLandscape ->Warn("Roe_Fawn:FFeed():NULL pointer,Mum!","");
242  exit( 1 );
243  }
244  #endif
245  m_MinInState[5]++; //add 1 to time spend in this state
246  m_LastState=38;
247 
248  m_EnergyGained += 75000; //during 10 minutes
249  //set care counter right if fawn is < 60 days
250  CareCounter(1);
251  //Does fawn want to initiate another careperiod?
252  int care=0;
253  for (int j=0; j<6; j++) //last 6 timesteps
254  {
255  if (m_CareLastHour[j]==1) care++;
256  }
257  #ifdef JUJ__Debug2
258  if(m_Agegroup>1)
259  {
260  m_OurLandscape ->Warn("Roe_Fawn:FFeed():m_AgeGroup > 1!","");
261  exit( 1 );
262  }
263  #endif
264 
265  if (care<Minhrcare[m_Agegroup]) //is still hungry
266  {
267  bool CanSuckle=Mum->On_InitCare(this);
268  if(CanSuckle==true)
269  {
271  //get distance to mum
273  {
274  WalkTo(xy.m_x,xy.m_y);
275  }
276  return 38; //Suckle
277  }
278  else return 37; //mother refused, so go to feed
279  }
280  else //fawn is satiated
281  {
282  Mum->On_EndCare(this); //end this careperiod
283  }
284  if (m_Age<14) return 29; //too young to feed so hide
285  else return 37;
286 }
void WalkTo(int pos_x, int pos_y)
Definition: Roe_base.cpp:1119
void On_EndCare(Roe_Fawn *Fawn)
Definition: Roe_female.cpp:2052

References CareCounter(), Roe_Base::DistanceTo(), Roe_Base::IsAlive(), Roe_Base::m_Age, m_Agegroup, m_CareLastHour, Roe_Base::m_EnergyGained, Roe_Base::m_LastState, TAnimal::m_Location_x, TAnimal::m_Location_y, m_MinInState, TAnimal::m_OurLandscape, AnimalPosition::m_x, AnimalPosition::m_y, Minhrcare, Roe_Base::Mum, Roe_Female::On_EndCare(), Roe_Female::On_InitCare(), TAnimal::SupplyPosition(), Roe_Base::WalkTo(), and Landscape::Warn().

Referenced by Step().

◆ FAUpdateEnergy()

int Roe_Fawn::FAUpdateEnergy ( void  )
private

Roe_Fawn::FAUpdateEnergy - Calculates how much energy is used (in cal/minute) in different activities. Calculates net energy (gained-used) and determines whether excess enery is added to reserves (fawns do not have reserves the first 2 months, if negative energy balance they immediately loose weight) or is used to put on weight. A negative net energy causes the fawn object to loose weight - if fawn weight falls below a minimum value, it will die. If the fawn is in very bad condition it will increase forage time. Returns states such as feed or die.

619 {
620  #ifdef JUJ__Debug3
621  if(IsAlive()!=0x0DEADC0DE)
622  {
623  m_OurLandscape ->Warn("Roe_Fawn:FAUpdateEnergy():Deadcode warning!","");
624  exit( 1 );
625  }
626  #endif
627  //all energetic calculations in cal.
628  //Calculate how much energy used in different activities
629  float EnergyUsed=0;
630  int month=m_OurLandscape->SupplyMonth();
631  for (int i=0; i<6; i++)
632  {
633  float cost;
634  if (CostFawnAct[i]==1) cost=FawnRMR;
635  else cost=(float) CostFawnAct[i];
636  EnergyUsed += (float) (cost * m_MinInState[i] * (m_Size*0.001));
637  }
638  //Note: Fawns do not have reserves the first 2 months. If negative energybalance,
639  //they immediately loose weight.
640  float result = m_EnergyGained - EnergyUsed; //in cal
641  if (result>0)
642  {
643  if((m_Age>60)&&(m_Reserves<5)) m_Reserves++; //increase reserves
644  else
645  {
646  m_Size += (int)floor(result * Anabolic_Inv); //put on weight
647  }
648  }
649  else if (result<0)
650  {
651  if((m_Age>60)&&(m_Reserves>0)) m_Reserves--; //loose reserves
652  else
653  {
654  m_Size += (int)floor(result*Catabolic_Inv); //loose weight
655  }
656  }
657  //get length of feeding period
658  if (m_Age>=60)
659  {
660  //adjust lenght of feeding bouts
661  m_LengthFeedPeriod = (int)(7*(m_Size*0.001)/
662  Female_FeedBouts[month-1]);
663  //if approaching lower critical bodyweight, increase feed period
664  if((m_Size < MinWeightFawn[m_Agegroup]+1500)
666  {
668  }
669  //If m_Size < MinSize roe dies
670  else if (m_Size < MinWeightFawn[m_Agegroup])
671  {
672  return 43;
673  }
674  }
675  //set counter of daily energy gain to zero
676  m_EnergyGained=0;
677  for(int i=0;i<6;i++)
678  {
679  m_MinInState[i]=0;
680  }
681  return m_LastState;
682 }
const int CostFawnAct[6]
Definition: Roe_constants.cpp:112
const float FawnRMR
Definition: Roe_constants.cpp:75
const float Catabolic_Inv
Definition: Roe_constants.cpp:123
const float Anabolic_Inv
Definition: Roe_constants.cpp:120
const int MinWeightFawn[5]
Definition: Roe_constants.cpp:81
const int Female_FeedBouts[12]
Definition: Roe_constants.cpp:91

References Anabolic_Inv, Catabolic_Inv, CostFawnAct, FawnRMR, Female_FeedBouts, Roe_Base::IsAlive(), Roe_Base::m_Age, m_Agegroup, Roe_Base::m_EnergyGained, Roe_Base::m_LastState, Roe_Base::m_LengthFeedPeriod, m_MinInState, TAnimal::m_OurLandscape, Roe_Base::m_Reserves, Roe_Base::m_Size, MinWeightFawn, Landscape::SupplyMonth(), and Landscape::Warn().

Referenced by Step().

◆ Mature()

void Roe_Fawn::Mature ( )
protected

Roe_Fawn::Mature - maturation of fawn into adult. Creates new adult object (male of female) in same geographical place as fawn and sets adult properties. Calls CreateObjects().

584 {
585  m_Mature=true;
586  //A new adult object is created
587  Deer_struct* ads;
588  ads=new Deer_struct;
589  int objecttype;
590 
591  if (m_Sex==true) objecttype=1; //male
592  else objecttype=2; //female
593  //call CreateObjects
594  ads->Pop = m_OurPopulation;
595  ads-> L = m_OurLandscape;
596  ads->x = m_Location_x;
597  ads->y = m_Location_y;
598  ads->mum = Mum;
599  ads->size = m_Size;
600  ads->age = m_Age;
601  ads->group = m_MyGroup;
602  //debug
603 
604  ads->ID = m_ID;
605  m_OurPopulation->CreateObjects(objecttype,this,NULL,ads,1);
606  delete ads;
607 }
Definition: Roe_all.h:437
int x
Definition: Roe_all.h:439
RoeDeer_Population_Manager * Pop
Definition: Roe_all.h:443
int age
Definition: Roe_all.h:447
int size
Definition: Roe_all.h:446
int ID
Definition: Roe_all.h:448
int y
Definition: Roe_all.h:440
int group
Definition: Roe_all.h:445
Roe_Female * mum
Definition: Roe_all.h:444
int m_ID
Definition: Roe_all.h:118
void CreateObjects(int, TAnimal *pvo, void *null, Deer_struct *data, int number)
Definition: Roe_Population_Manager.cpp:1268

References Deer_struct::age, RoeDeer_Population_Manager::CreateObjects(), Deer_struct::group, Deer_struct::ID, Roe_Base::m_Age, Roe_Base::m_ID, TAnimal::m_Location_x, TAnimal::m_Location_y, m_Mature, m_MyGroup, TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, Roe_Base::m_Sex, Roe_Base::m_Size, Roe_Base::Mum, Deer_struct::mum, Deer_struct::Pop, Deer_struct::size, Deer_struct::x, and Deer_struct::y.

Referenced by FAOnNewDay().

◆ On_ApproachOfDanger()

void Roe_Fawn::On_ApproachOfDanger ( int  p_To_x,
int  p_To_y 
)
protected

Roe_Fawn::On_ApproachOfDanger - determines fawn behavior when exposed to a threath. When fawn < 60 days it either hides or runs to mother depending on flush distance (this is again depending on age group of fawn). When > 60 days it always runs either towards mother (if not an orphan) or away from threath. Calls DistanceTo(), Running().

1383 {
1384  //when fawn < 60 days it either hides or runs to mother. When > 60 days it
1385  //always runs
1386  if (m_Age<60)
1387  {
1388  //get distance to threat
1390  {
1392  }
1394  }
1395  else //more than 2 months old, never hides
1396  {
1398  else
1399  {
1400  Running(p_To_x,p_To_y);
1403  }
1404  }
1405 }
@ rds_FARunToMother
Definition: Roe_all.h:67
@ rds_FARecover
Definition: Roe_all.h:70
@ rds_FAHide
Definition: Roe_all.h:75
@ rds_FADie
Definition: Roe_all.h:89
const int Flush_dist[2]
Definition: Roe_constants.cpp:151
bool Running(int x, int y)
Definition: Roe_base.cpp:380

References Roe_Base::CurrentRState, Roe_Base::DistanceTo(), Flush_dist, Roe_Base::m_Age, m_Agegroup, Roe_Base::m_IsDead, TAnimal::m_Location_x, TAnimal::m_Location_y, m_Orphan, rds_FADie, rds_FAHide, rds_FARecover, rds_FARunToMother, and Roe_Base::Running().

◆ On_ChangeGroup()

void Roe_Fawn::On_ChangeGroup ( int  newgroup)
virtual

Roe_Fawn::On_ChangeGroup - removes fawn object from old group and add it to new group. Calls RemoveFromGroup(), AddToGroup().

Reimplemented from Roe_Base.

1451 {
1452  //remove yourself from your old group
1454  //change groupnumber
1455  m_MyGroup=newgroup;
1456  //add yourself to the new group
1458 }
bool AddToGroup(Roe_Base *p_deer, int TheGroup)
Definition: Roe_Population_Manager.cpp:1397

References RoeDeer_Population_Manager::AddToGroup(), m_MyGroup, Roe_Base::m_OurPopulation, and RoeDeer_Population_Manager::RemoveFromGroup().

◆ On_EndGroup()

void Roe_Fawn::On_EndGroup ( )
virtual

Reimplemented from Roe_Base.

1442 {
1443 
1444 }

◆ On_IsDead()

void Roe_Fawn::On_IsDead ( Roe_Base Someone,
int  whos_dead,
bool  fawn 
)
virtual

Roe_Fawn::On_IsDead - governs a fawn objects "response" to death of another object. If dead object is mother and fawn is less than 60days, the fawn will die. Else it is set to be an orphan. If same-age sibling is dead, sibling is removed from sibling list.

Reimplemented from Roe_Base.

1302 {
1303  #ifdef JUJ__Debug3
1304  if(Someone->IsAlive()!=0x0DEADC0DE)
1305  {
1306  m_OurLandscape ->Warn("Roe_Fawn:On_IsDead():Deadcode warning, someone!","");
1307  exit( 1 );
1308  }
1309  if(IsAlive()!=0x0DEADC0DE)
1310  {
1311  m_OurLandscape ->Warn("Roe_Fawn:On_IsDead(): Deadcode warning","");
1312  exit( 1 );
1313  }
1314  #endif
1315  if (whos_dead==0) //mother is dead
1316  {
1317  Mum=NULL; //remove pointer to mother
1318  if (m_Age <= 60) //fawn will not survive alone
1319  {
1320  m_IsDead=true;
1322  }
1323  else
1324  {
1325  m_Orphan=true;
1326  }
1327  }
1328  else if (whos_dead==4) //same-age sibling
1329  {
1330  //remove from m_MySiblings[]
1331  for (int i=0; i<3; i++)
1332  {
1333  #ifdef JUJ__Debug3
1334  if(m_MySiblings[i]!=NULL) if(m_MySiblings[i]->IsAlive()!=0x0DEADC0DE)
1335  {
1336  m_OurLandscape ->Warn("Roe_Fawn:On_IsDead(): Bad pointer, m_MySiblings","");
1337  exit( 1 );
1338  }
1339  #endif
1340  if (m_MySiblings[i]==Someone)
1341  {
1342  m_MySiblings[i]=NULL; //remove pointer to that sibling
1343  }
1344  }
1345  }
1346 }

References Roe_Base::CurrentRState, Roe_Base::IsAlive(), Roe_Base::m_Age, Roe_Base::m_IsDead, m_MySiblings, m_Orphan, TAnimal::m_OurLandscape, Roe_Base::Mum, rds_FADie, and Landscape::Warn().

◆ On_MumAbandon()

void Roe_Fawn::On_MumAbandon ( Roe_Female mum)
virtual

Roe_Fawn::On_MumAbandon - fawn response to mother abandoning it. Mum is deleted, if fawn is less than 2 months it will die, otherwise it is set as orphaned.

Reimplemented from Roe_Base.

1353 {
1354  #ifdef JUJ__Debug1
1355  if((mum!=Mum)||(Mum==NULL))
1356  {
1357  m_OurLandscape ->Warn("Roe_Fawn:On_MumAbandon: Bad pointer, Mum","");
1358  exit( 1 );
1359  }
1360  #endif
1361  Mum=NULL; //don't need to tell mum because she already deletes her fawn list
1362  if(m_Age<=60)
1363  {
1364  m_IsDead=true; //fawn will not survive
1366  }
1367  else
1368  {
1369  m_Orphan=true;
1370  }
1371 }

References Roe_Base::CurrentRState, Roe_Base::m_Age, Roe_Base::m_IsDead, m_Orphan, TAnimal::m_OurLandscape, Roe_Base::Mum, rds_FADie, and Landscape::Warn().

◆ On_UpdateGroup()

void Roe_Fawn::On_UpdateGroup ( int  p_group_x,
int  p_group_y 
)
protectedvirtual

Reimplemented from Roe_Base.

1435 {
1436  //fawns do not need to know about where the rangecentre is, since they always
1437  //position themselves according to their mothers position
1438 }

◆ RunTo()

int Roe_Fawn::RunTo ( int  mum_x,
int  mum_y,
bool  p_IsSafe 
)
protected

Roe_Fawn::RunTo - directed movement towards mothers position, all habitat except lethal habitat is used. Roads can be crossed and probability of dying is calculated. Calls functions DirectionTo(), DistanceTo(), SupplyElementType(), SupplyRoadWidth(), CalculateRoadMortality(),

1034 {
1035  //directed movement towards mothers position, all habitat except lethal
1036  //habitat is used. Roads can be crossed
1037  int t[8];
1038  int q[8];
1039  int thisfar=0; //run this far in one timestep
1040  int x=m_Location_x;
1041  int y=m_Location_y;
1042  //First get direction and distance to Mum
1043  int dir=DirectionTo(x,y,mum_x,mum_y);
1044  int dist=DistanceTo(x,y,mum_x,mum_y);
1045  //and direction to threat
1046  int threat_dir=DirectionTo(x,y,m_danger_x,m_danger_y);
1047  if (dist<100) thisfar=dist;
1048  else thisfar=100;
1049  //Is it possible to go in that direction
1050  for (int i=0; i<thisfar; i++)
1051  {
1052  t[0]=dir;
1053  t[0]=(t[0]+8) & 7;
1054  q[0]=m_OurLandscape->SupplyElementType(x+Vector_x[t[0]],y+Vector_y[t[0]]);
1055  if ((q[0]<tole_SmallRoad)&&(t[0]!=threat_dir)) //OK
1056  {
1057  //change coordinates
1058  x+=Vector_x[t[0]];
1059  y+=Vector_y[t[0]];
1060  }
1061  else //not possible, so check all other directions except dir+4
1062  {
1063  t[1]=dir-1;
1064  t[1]=(t[1]+8) & 7;
1065  t[2]=dir+1;
1066  t[2]=(t[2]+8) & 7;
1067  t[3]=dir-2;
1068  t[3]=(t[3]+8) & 7;
1069  t[4]=dir+2;
1070  t[4]=(t[4]+8) & 7;
1071  t[5]=dir+3;
1072  t[5]=(t[5]+8) & 7;
1073  t[6]=dir-3;
1074  t[6]=(t[6]+8) & 7;
1075  q[1]=m_OurLandscape->SupplyElementType(x+Vector_x[t[1]],y+Vector_y[t[1]]);
1076  q[2]=m_OurLandscape->SupplyElementType(x+Vector_x[t[2]],y+Vector_y[t[2]]);
1077  q[3]=m_OurLandscape->SupplyElementType(x+Vector_x[t[3]],y+Vector_y[t[3]]);
1078  q[4]=m_OurLandscape->SupplyElementType(x+Vector_x[t[4]],y+Vector_y[t[4]]);
1079  q[5]=m_OurLandscape->SupplyElementType(x+Vector_x[t[5]],y+Vector_y[t[5]]);
1080  q[6]=m_OurLandscape->SupplyElementType(x+Vector_x[t[6]],y+Vector_y[t[6]]);
1081  for (int j=1; j<6;j++)
1082  {
1083  if ((q[j]<tole_SmallRoad)&&(t[j]!=threat_dir))
1084  {
1085  x+=Vector_x[t[j]];
1086  y+=Vector_y[t[j]];
1087  break;
1088  }
1089  else if (q[j]==int (tole_SmallRoad||tole_LargeRoad)) //only option available is road habitat
1090  {
1091  //get width of road
1092  int width=m_OurLandscape->SupplyRoadWidth(x+Vector_x[t[j]],y+Vector_y[t[j]]);
1093  float mort=CalculateRoadMortality(x+Vector_x[t[j]],y+Vector_y[t[j]],width);
1094  int die=random(100);
1095  if (die<mort) //fawn dies
1096  {
1097  m_IsDead=true;
1098  }
1099  else
1100  {
1101  x+=Vector_x[t[j]];
1102  y+=Vector_y[t[j]];
1103  break;
1104  }
1105  }
1106  }
1107  }
1108  //change roes position
1109  m_Location_x=x;
1110  m_Location_y=y;
1111 
1112  //finished running 100 steps so check if safe
1114  if (threat_dist > 100)
1115  {
1116  return 1; //doesn't matter how far from mum, is safe
1117  }
1118  else //get new dist to see if with mum
1119  {
1120  dist=DistanceTo(x,y,mum_x,mum_y);
1121  if (dist > 2) //not safe
1122  {
1123  return 0;
1124  }
1125  }
1126  }
1127  return 1;
1128 }
const int Vector_x[8]
const int Vector_y[8]
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1110
int SupplyRoadWidth(int, int)
Definition: landscape.h:811
double CalculateRoadMortality(int p_x, int p_y, int p_width)
Definition: Roe_base.cpp:1093
int m_danger_x
Definition: Roe_all.h:139
int m_danger_y
Definition: Roe_all.h:140
@ tole_SmallRoad
Definition: tole_declaration.h:60
@ tole_LargeRoad
Definition: tole_declaration.h:61

References Roe_Base::CalculateRoadMortality(), Roe_Base::DirectionTo(), Roe_Base::DistanceTo(), Roe_Base::m_danger_x, Roe_Base::m_danger_y, Roe_Base::m_IsDead, TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, random(), Landscape::SupplyElementType(), Landscape::SupplyRoadWidth(), tole_LargeRoad, tole_SmallRoad, Vector_x, and Vector_y.

Referenced by FARunToMother().

◆ SelectBedSite()

void Roe_Fawn::SelectBedSite ( )
protected

Roe_Fawn::SelectBedSite - function for selecting a good spot to hide. Fawn ob ject checks habitat type at location. Good habitat is forest type vegetation, or open land if vegetation is high enough. New bed site is added to bed site list. If not able to find new bed site search bed site list and move to closest bed site. Calls SupplyElementType(), SupplyVegHeight(), DistanceTo(), WalkTo(), SeekCover().

1138 {
1140  SupplyElementType(m_Location_x,m_Location_y);
1141  //forest type vegetation
1142  if ((Elem >= tole_PitDisused)&&(Elem < tole_StoneWall)||(Elem==tole_Hedges))
1143  {
1144  // add new bedsite to bedsite list
1145  m_memorypointer ++;
1146  if (m_memorypointer>=15) {
1147  m_memorypointer = 0;
1148  }
1149  // **FN**
1150  // A test is much faster than a modulus, which is a division, of
1151  // course.
1152  //m_memorypointer = m_memorypointer % 15;
1153  #ifdef JUJ__Debug2
1154  if(m_memorypointer>=15)
1155  {
1156  m_OurLandscape ->Warn("Roe_Fawn:SelectBedSite():Variable out of range,m_memorycounter!","");
1157  exit( 1 );
1158  }
1159  #endif
1162  }
1163  else if ((Elem > tole_Railway)&&(Elem < tole_PitDisused)) //open land
1164  {
1165  //get VegHeight
1166  float VegHeight=(float) m_OurLandscape->SupplyVegHeight(m_Location_x,
1167  m_Location_y);
1168  if (VegHeight>70) //OK hide on spot
1169  {
1170  // add new bedsite to bedsite list
1171  m_memorypointer ++;
1172  if(m_memorypointer>=15) {
1173  m_memorypointer = 0;
1174  }
1175  //m_memorypointer = m_memorypointer % 15;
1176  #ifdef JUJ__Debug2
1177  if(m_memorypointer>=15)
1178  {
1179  m_OurLandscape ->Warn("Roe_Fawn:SelectBedSite():Variable out of range,m_memorycounter!","");
1180  exit( 1 );
1181  }
1182  #endif
1185  }
1186  }
1187  else //not good here, check bedsitelist
1188  {
1189  int pick=0;
1190  if (BedSiteList[0][0] == -1) pick = -1; //list empty
1191  else
1192  {
1193  for(int i=0; i<15; i++)
1194  {
1195  int best=100;
1197  BedSiteList[i][0],BedSiteList[i][1]);
1198  if(dist<best)
1199  {
1200  pick=i;
1201  break;
1202  }
1203  else pick=-1; //no bedsites nearby
1204  }
1205  }
1206  if (pick != -1)
1207  {
1208  #ifdef JUJ__Debug2
1209  if(pick>=15)
1210  {
1211  m_OurLandscape ->Warn("Roe_Fawn:SelectBedSite():Variable out of range,pick!","");
1212  exit( 1 );
1213  }
1214  #endif
1215  WalkTo(BedSiteList[pick][0],BedSiteList[pick][1]);
1216  //up to 150 steps, so fawn will always get there in 1 timestep
1217  }
1218  else //nothing found
1219  {
1220  SeekCover(2);
1221  // add new bedsite to bedsite list
1222  m_memorypointer ++;
1223  if(m_memorypointer>=15) {
1224  m_memorypointer = 0;
1225  }
1226 
1227  // m_memorypointer = m_memorypointer % 15;
1228  #ifdef JUJ__Debug2
1229  if(m_memorypointer>=15)
1230  {
1231  m_OurLandscape ->Warn("Roe_Fawn:SelectBedSite():Variable out of range,m_memorycounter!","");
1232  exit( 1 );
1233  }
1234  #endif
1237  }
1238  }
1239 }
double SupplyVegHeight(int a_polyref)
Definition: landscape.h:936
TTypesOfLandscapeElement
Definition: tole_declaration.h:36
@ tole_StoneWall
Definition: tole_declaration.h:56
@ tole_Hedges
Definition: tole_declaration.h:37
@ tole_PitDisused
Definition: tole_declaration.h:50
@ tole_Railway
Definition: tole_declaration.h:39

References BedSiteList, Roe_Base::DistanceTo(), TAnimal::m_Location_x, TAnimal::m_Location_y, m_memorypointer, TAnimal::m_OurLandscape, Roe_Base::SeekCover(), Landscape::SupplyVegHeight(), tole_Hedges, tole_PitDisused, tole_Railway, tole_StoneWall, Roe_Base::WalkTo(), and Landscape::Warn().

Referenced by FAHide().

◆ Send_InitCare()

void Roe_Fawn::Send_InitCare ( )
protected

Roe_Fawn::Send_InitCare - sends message to mother asking if it can feed. If message returns true, the fawn will be in the suckle state, otherwise feeding state.

1412 {
1413  #ifdef JUJ__Debug1
1414  if(Mum==NULL)
1415  {
1416  m_OurLandscape ->Warn("Roe_Fawn:Send_InitCare():NUL pointer","");
1417  exit( 1 );
1418  }
1419  #endif
1420 
1421  bool CanFeed = Mum->On_InitCare(this); //send message to mum and get answer
1422  if (CanFeed==true)
1423  {
1425  }
1426  else
1427  {
1429  }
1430 }
@ rds_FAFeed
Definition: Roe_all.h:83
@ rds_FASuckle
Definition: Roe_all.h:84

References Roe_Base::CurrentRState, TAnimal::m_OurLandscape, Roe_Base::Mum, Roe_Female::On_InitCare(), rds_FAFeed, rds_FASuckle, and Landscape::Warn().

◆ Step()

void Roe_Fawn::Step ( void  )
virtual

Roe_Fawn::Step - function called every time step. The functions checks if done with a given state (m_StepDone) and governs states and transitions to other states. Calls functions: FAInit(), FADie(), FAOnNEwDay(), FAUpdateEnergy(), FASuckle(), FAFeed(), FARuminate(), FARunToMother(), FARecover(), FAHide().

Reimplemented from Roe_Base.

768 {
769  #ifdef JUJ__Debug3
770  if(IsAlive()!=0x0DEADC0DE)
771  {
772  m_OurLandscape ->Warn("Roe_Fawn:Step():Deadcode warning!","");
773  exit( 1 );
774  }
775  #endif
776  if (m_StepDone || (CurrentRState==rds_FADeathState)) return;
777 
778  switch (CurrentRState)
779  {
780  case rds_Initialise:
782  break;
783  case rds_FAInit:
784  switch(FAInit())
785  {
786  case 38:
788  break;
789  default:
790  m_OurLandscape ->Warn("Roe_Fawn:Step():rds_FAInit: no matching case!","");
791  exit( 1 );
792  break;
793  }
794  m_StepDone=true;
795  break;
796  case rds_FADie:
797  switch (FADie())
798  {
799  case 46:
801  break;
802  default:
803  m_OurLandscape ->Warn("Roe_Fawn:Step():rds_FADie: no matching case!","");
804  exit( 1 );
805  break;
806  }
807  m_StepDone=true;
808  break;
809 
810  case rds_FAOnNewDay:
811  switch (FAOnNewDay())
812  {
813  case 6: //update energy
815  m_StepDone=true;
816  break;
817  case 43: //died or matured
819  break;
820  default:
821  m_OurLandscape ->Warn("Roe_Fawn:Step():rds_FAOnNewDay: no matching case!","");
822  exit( 1 );
823  break;
824  }
825  break;
826 
827  case rds_FAUpdateEnergy:
828  switch (FAUpdateEnergy())
829  {
830  case 24: //rds_FARecover
832  m_StepDone=true;
833  break;
834  case 29:
836  m_StepDone=true;
837  break;
838  case 34: //rds_FARuminate
840  m_StepDone=true;
841  break;
842  case 37: //rds_FAFeed
844  m_StepDone=true;
845  break;
846  case 38: //suckle
848  m_StepDone=true;
849  break;
850  case 43: //rds_FADie:
852  break;
853  default:
854  m_OurLandscape ->Warn("Roe_Fawn:Step():rds_FAUpdateEnergy: no matching case!","");
855  exit( 1 );
856  break;
857  }
858  break;
859  case rds_FASuckle:
860  switch (FASuckle())
861  {
862  case 37: //rds_FAFeed:
864  break;
865  case 29: //rds_FAHide:
867  break;
868  case 38: //suckle
870  break;
871  default:
872  m_OurLandscape ->Warn("Roe_Fawn:Step():rds_FASuckle: no matching case!","");
873  exit( 1 );
874  break;
875  }
876  m_StepDone=true;
877  break;
878 
879  case rds_FAFeed:
880  switch (FAFeed())
881  {
882  case 29: //rds_FAHide:
884  break;
885  case 37: //rds_FAFeed:
887  break;
888  case 38: //rds_FASuckle:
890  break;
891  case 34: //rds_FARuminate:
893  break;
894  default:
895  m_OurLandscape ->Warn("Roe_Fawn:Step():rds_FAFeed: no matching case!","");
896  exit( 1 );
897  break;
898  }
899  m_StepDone=true;
900  break;
901 
902  case rds_FARuminate:
903  switch (FARuminate())
904  {
905  case 37: //rds_FAFeed:
907  m_StepDone=true;
908  break;
909  case 34: //rds_FARuminate:
911  m_StepDone=true;
912  break;
913  case 43:
915  break;
916  default:
917  m_OurLandscape ->Warn("Roe_Fawn:Step():rds_FARuminate: no matching case!","");
918  exit( 1 );
919  break;
920  }
921  break;
922 
923  case rds_FARunToMother:
924  switch (FARunToMother())
925  {
926  case 24: //rds_FARecover:
928  break;
929  case 21: //rds_FARunToMother
931  break;
932  default:
933  m_OurLandscape ->Warn("Roe_Fawn:Step():rds_FARunToMother: no matching case!","");
934  exit( 1 );
935  break;
936  }
937  m_StepDone=true;
938  break;
939 
940  case rds_FARecover:
941  switch (FARecover())
942  {
943  case 37: //rds_FAFeed:
945  break;
946  case 38: //rds_FASuckle:
948  break;
949  case 24: //rds_FARecover:
951  break;
952  default:
953  m_OurLandscape ->Warn("Roe_Fawn:Step():rds_FARecover: no matching case!","");
954  exit( 1 );
955  break;
956  }
957  m_StepDone=true;
958  break;
959  case rds_FAHide:
960  switch (FAHide())
961  {
962  case 37: //rds_FAFeed:
964  break;
965  case 38: //rds_FASuckle:
967  break;
968  case 29: //rds_FAHide
970  break;
971  default:
972  m_OurLandscape ->Warn("Roe_Fawn:Step():rds_FAHide: no matching case!","");
973  exit( 1 );
974  break;
975  }
976  m_StepDone=true;
977  break;
978  default:
979  m_OurLandscape ->Warn("Roe_Fawn:Step(): no matching case!","");
980  exit( 1 );
981  }
982 }
@ rds_FAInit
Definition: Roe_all.h:93
@ rds_FAUpdateEnergy
Definition: Roe_all.h:52
@ rds_FARuminate
Definition: Roe_all.h:80
@ rds_Initialise
Definition: Roe_all.h:46
int FARuminate(void)
Definition: Roe_fawn.cpp:297
int FARunToMother(void)
Definition: Roe_fawn.cpp:501
int FAHide(void)
Definition: Roe_fawn.cpp:361
int FARecover(void)
Definition: Roe_fawn.cpp:426
int FADie(void)
Definition: Roe_fawn.cpp:691
int FAFeed(void)
Definition: Roe_fawn.cpp:79
int FASuckle(void)
Definition: Roe_fawn.cpp:222
int FAInit(void)
Definition: Roe_fawn.cpp:28
int FAUpdateEnergy(void)
Definition: Roe_fawn.cpp:618
int FAOnNewDay(void)
Definition: Roe_fawn.cpp:538
bool m_StepDone
Indicates whether the iterative step code is done for this timestep.
Definition: PopulationManager.h:118

References Roe_Base::CurrentRState, FADie(), FAFeed(), FAHide(), FAInit(), FAOnNewDay(), FARecover(), FARuminate(), FARunToMother(), FASuckle(), FAUpdateEnergy(), Roe_Base::IsAlive(), TAnimal::m_OurLandscape, TALMaSSObject::m_StepDone, rds_FADeathState, rds_FADie, rds_FAFeed, rds_FAHide, rds_FAInit, rds_FAOnNewDay, rds_FARecover, rds_FARuminate, rds_FARunToMother, rds_FASuckle, rds_FAUpdateEnergy, rds_Initialise, and Landscape::Warn().

Member Data Documentation

◆ BedSiteList

int Roe_Fawn::BedSiteList[15][2]
protected

Referenced by Roe_Fawn(), and SelectBedSite().

◆ m_Agegroup

int Roe_Fawn::m_Agegroup
protected

◆ m_Bedsite_x

int Roe_Fawn::m_Bedsite_x
protected

Referenced by Roe_Fawn().

◆ m_BedSite_y

int Roe_Fawn::m_BedSite_y
protected

Referenced by Roe_Fawn().

◆ m_CareLastHour

int Roe_Fawn::m_CareLastHour[6]
protected

◆ m_Count

unsigned Roe_Fawn::m_Count
protected

Referenced by CareCounter(), and Roe_Fawn().

◆ m_InHide

bool Roe_Fawn::m_InHide
protected

Referenced by FAHide(), and Roe_Fawn().

◆ m_Mature

bool Roe_Fawn::m_Mature
protected

Referenced by Mature(), and Roe_Fawn().

◆ m_memorypointer

int Roe_Fawn::m_memorypointer
protected

Referenced by Roe_Fawn(), and SelectBedSite().

◆ m_MinHourlyCare

int Roe_Fawn::m_MinHourlyCare
protected

Referenced by Roe_Fawn().

◆ m_MinInState

int Roe_Fawn::m_MinInState[6]

◆ m_MyGroup

int Roe_Fawn::m_MyGroup

◆ m_MySiblings

Roe_Base* Roe_Fawn::m_MySiblings[3]
protected

◆ m_Orphan

bool Roe_Fawn::m_Orphan
protected

The documentation for this class was generated from the following files: